#include "Console.h"
#include "../text/StringTools.h"

#include <locale.h>
#include <wchar.h>

ConsoleImplementation& Console = ConsoleImplementation::SINGLETON;

ConsoleImplementation::ConsoleImplementation() {}

bool initialized = false;

void initialize()
{
	if(initialized)
		return;

	if (!setlocale(LC_CTYPE, ""))
	{
		throw "Can't set the default locale";
	}
}

void ConsoleImplementation::doprint(String& in)
{
	initialize();

	uchar* tmp = StringTools::toNativeString(in);

	wprintf(L"%ls", (uchar*)(void*)tmp);

	delete [] tmp;
}

ConsoleImplementation ConsoleImplementation::SINGLETON;
